동시 실행

您所在的位置:网站首页 python terminate 동시 실행

동시 실행

2023-06-27 07:49| 来源: 网络整理| 查看: 265

동시 실행¶

이 장에서 설명하는 모듈은 코드의 동시 실행을 지원합니다. 적절한 도구 선택은 실행할 작업(CPU 병목 대 IO 병목)과 선호하는 개발 스타일(이벤트 구동 협력적 다중작업 대 선점적 다중작업)에 따라 달라집니다. 다음은 개요입니다:

threading — 스레드 기반 병렬 처리 active_count() current_thread() excepthook() __excepthook__ get_ident() get_native_id() enumerate() main_thread() settrace() settrace_all_threads() gettrace() setprofile() setprofile_all_threads() getprofile() stack_size() TIMEOUT_MAX 스레드 로컬 데이터 local Thread 객체 Thread Thread.start() Thread.run() Thread.join() Thread.name Thread.getName() Thread.setName() Thread.ident Thread.native_id Thread.is_alive() Thread.daemon Thread.isDaemon() Thread.setDaemon() Lock 객체 Lock Lock.acquire() Lock.release() Lock.locked() RLock 객체 RLock RLock.acquire() RLock.release() Condition 객체 Condition Condition.acquire() Condition.release() Condition.wait() Condition.wait_for() Condition.notify() Condition.notify_all() Semaphore 객체 Semaphore Semaphore.acquire() Semaphore.release() BoundedSemaphore Semaphore 예 Event 객체 Event Event.is_set() Event.set() Event.clear() Event.wait() Timer 객체 Timer Timer.cancel() Barrier 객체 Barrier Barrier.wait() Barrier.reset() Barrier.abort() Barrier.parties Barrier.n_waiting Barrier.broken BrokenBarrierError with 문으로 록, 조건 및 세마포어 사용하기 multiprocessing — 프로세스 기반 병렬 처리 소개 Process 클래스 컨텍스트 및 시작 방법 프로세스 간 객체 교환 프로세스 간 동기화 프로세스 간 상태 공유 작업자 풀 사용 레퍼런스 Process와 예외 Process Process.run() Process.start() Process.join() Process.name Process.is_alive() Process.daemon Process.pid Process.exitcode Process.authkey Process.sentinel Process.terminate() Process.kill() Process.close() ProcessError BufferTooShort AuthenticationError TimeoutError 파이프와 큐 Pipe() Queue Queue.qsize() Queue.empty() Queue.full() Queue.put() Queue.put_nowait() Queue.get() Queue.get_nowait() Queue.close() Queue.join_thread() Queue.cancel_join_thread() SimpleQueue SimpleQueue.close() SimpleQueue.empty() SimpleQueue.get() SimpleQueue.put() JoinableQueue JoinableQueue.task_done() JoinableQueue.join() 잡동사니 active_children() cpu_count() current_process() parent_process() freeze_support() get_all_start_methods() get_context() get_start_method() set_executable() set_forkserver_preload() set_start_method() Connection 객체 Connection Connection.send() Connection.recv() Connection.fileno() Connection.close() Connection.poll() Connection.send_bytes() Connection.recv_bytes() Connection.recv_bytes_into() 동기화 프리미티브 Barrier BoundedSemaphore Condition Event Lock Lock.acquire() Lock.release() RLock RLock.acquire() RLock.release() Semaphore 공유 ctypes 객체 Value() Array() multiprocessing.sharedctypes 모듈 RawArray() RawValue() Array() Value() copy() synchronized() 관리자 multiprocessing.Manager() BaseManager BaseManager.start() BaseManager.get_server() BaseManager.connect() BaseManager.shutdown() BaseManager.register() BaseManager.address SyncManager SyncManager.Barrier() SyncManager.BoundedSemaphore() SyncManager.Condition() SyncManager.Event() SyncManager.Lock() SyncManager.Namespace() SyncManager.Queue() SyncManager.RLock() SyncManager.Semaphore() SyncManager.Array() SyncManager.Value() SyncManager.dict() SyncManager.list() Namespace 사용자 정의 관리자 원격 관리자 사용하기 프락시 객체 BaseProxy BaseProxy._callmethod() BaseProxy._getvalue() BaseProxy.__repr__() BaseProxy.__str__() 정리 프로세스 풀 Pool Pool.apply() Pool.apply_async() Pool.map() Pool.map_async() Pool.imap() Pool.imap_unordered() Pool.starmap() Pool.starmap_async() Pool.close() Pool.terminate() Pool.join() AsyncResult AsyncResult.get() AsyncResult.wait() AsyncResult.ready() AsyncResult.successful() 리스너와 클라이언트 deliver_challenge() answer_challenge() Client() Listener Listener.accept() Listener.close() Listener.address Listener.last_accepted wait() 주소 형식 인증 키 로깅 get_logger() log_to_stderr() multiprocessing.dummy 모듈 ThreadPool 프로그래밍 지침 모든 시작 방법 spawn 과 forkserver 시작 방법 예제 multiprocessing.shared_memory — Shared memory for direct access across processes SharedMemory SharedMemory.close() SharedMemory.unlink() SharedMemory.buf SharedMemory.name SharedMemory.size SharedMemoryManager SharedMemoryManager.SharedMemory() SharedMemoryManager.ShareableList() ShareableList ShareableList.count() ShareableList.index() ShareableList.format ShareableList.shm concurrent 패키지 concurrent.futures — 병렬 작업 실행하기 Executor 객체 Executor Executor.submit() Executor.map() Executor.shutdown() ThreadPoolExecutor ThreadPoolExecutor ThreadPoolExecutor 예제 ProcessPoolExecutor ProcessPoolExecutor ProcessPoolExecutor 예제 Future 객체 Future Future.cancel() Future.cancelled() Future.running() Future.done() Future.result() Future.exception() Future.add_done_callback() Future.set_running_or_notify_cancel() Future.set_result() Future.set_exception() 모듈 함수 wait() as_completed() 예외 클래스 CancelledError TimeoutError BrokenExecutor InvalidStateError BrokenThreadPool BrokenProcessPool subprocess — 서브 프로세스 관리 subprocess 모듈 사용하기 run() CompletedProcess CompletedProcess.args CompletedProcess.returncode CompletedProcess.stdout CompletedProcess.stderr CompletedProcess.check_returncode() DEVNULL PIPE STDOUT SubprocessError TimeoutExpired TimeoutExpired.cmd TimeoutExpired.timeout TimeoutExpired.output TimeoutExpired.stdout TimeoutExpired.stderr CalledProcessError CalledProcessError.returncode CalledProcessError.cmd CalledProcessError.output CalledProcessError.stdout CalledProcessError.stderr 자주 사용되는 인자 Popen 생성자 Popen 예외 보안 고려 사항 Popen 객체 Popen.poll() Popen.wait() Popen.communicate() Popen.send_signal() Popen.terminate() Popen.kill() Popen.args Popen.stdin Popen.stdout Popen.stderr Popen.pid Popen.returncode 윈도우 Popen 도우미 STARTUPINFO STARTUPINFO.dwFlags STARTUPINFO.hStdInput STARTUPINFO.hStdOutput STARTUPINFO.hStdError STARTUPINFO.wShowWindow STARTUPINFO.lpAttributeList 윈도우 상수 STD_INPUT_HANDLE STD_OUTPUT_HANDLE STD_ERROR_HANDLE SW_HIDE STARTF_USESTDHANDLES STARTF_USESHOWWINDOW CREATE_NEW_CONSOLE CREATE_NEW_PROCESS_GROUP ABOVE_NORMAL_PRIORITY_CLASS BELOW_NORMAL_PRIORITY_CLASS HIGH_PRIORITY_CLASS IDLE_PRIORITY_CLASS NORMAL_PRIORITY_CLASS REALTIME_PRIORITY_CLASS CREATE_NO_WINDOW DETACHED_PROCESS CREATE_DEFAULT_ERROR_MODE CREATE_BREAKAWAY_FROM_JOB 오래된 고수준 API call() check_call() check_output() 이전 함수를 subprocess 모듈로 교체하기 /bin/sh 셸 명령 치환 교체하기 셸 파이프라인 교체하기 os.system() 교체하기 os.spawn 패밀리 교체하기 os.popen(), os.popen2(), os.popen3() 교체하기 popen2 모듈의 함수 교체하기 레거시 셸 호출 함수 getstatusoutput() getoutput() 노트 윈도우에서 인자 시퀀스를 문자열로 변환하기 Disabling use of vfork() or posix_spawn() sched — 이벤트 스케줄러 scheduler 스케줄러 객체 scheduler.enterabs() scheduler.enter() scheduler.cancel() scheduler.empty() scheduler.run() scheduler.queue queue — 동기화된 큐 클래스 Queue LifoQueue PriorityQueue SimpleQueue Empty Full 큐 객체 Queue.qsize() Queue.empty() Queue.full() Queue.put() Queue.put_nowait() Queue.get() Queue.get_nowait() Queue.task_done() Queue.join() SimpleQueue 객체 SimpleQueue.qsize() SimpleQueue.empty() SimpleQueue.put() SimpleQueue.put_nowait() SimpleQueue.get() SimpleQueue.get_nowait() contextvars — 컨텍스트 변수 컨텍스트 변수 ContextVar ContextVar.name ContextVar.get() ContextVar.set() ContextVar.reset() Token Token.var Token.old_value Token.MISSING 수동 컨텍스트 관리 copy_context() Context Context.run() Context.copy() Context.get() Context.keys() Context.values() Context.items() asyncio 지원

다음은 위 서비스 중 일부에 대한 지원 모듈입니다:

_thread — 저수준 스레드 API error LockType start_new_thread() interrupt_main() exit() allocate_lock() get_ident() get_native_id() stack_size() TIMEOUT_MAX lock.acquire() lock.release() lock.locked()


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3